package com.mc.lp.shared.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
 * @author aphanda
 * @date Oct 14, 2014
 * @time 12:55:13 AM
 */

public class DateUtil {

	
	public static void main(String[] args) {
		String dateInString ="2014-09-28T18:30:00.000Z";
		
		String date = convertDate2StringDate(new Date(), "dd-MMMM-yyyy");
		
		System.out.println(date);
	}
	
	
	public static String convertDate2StringDate(Date date, String format) {
		String strDate = null;

		SimpleDateFormat df = new SimpleDateFormat(format);
		if(date!=null)
		strDate = df.format(date);
		else
		strDate=df.format(new Date());	
		return strDate;
	}
	
	
	public static Date convertString2Date(String dateInString, String format) {
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		Date date = null;

		try {
			date = formatter.parse(dateInString);
			System.out.println(date);
			System.out.println(formatter.format(date));

		} catch (ParseException e) {
			date= new Date();
			e.printStackTrace();
		}
		return date;
	}
}
